{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import joblib\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "from functools import reduce\n",
    "from datetime import timedelta"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "input_dir = './train_plc_RULR/'\n",
    "output_dir = './plc_features/'\n",
    "if not os.path.exists('./plc_features'):\n",
    "    os.mkdir('./plc_features')\n",
    "\n",
    "df_list = [joblib.load(input_dir + 'train_0%d_plc.lz4' % i) for i in [1, 2, 3]]\n",
    "\n",
    "for i in range(len(df_list)):\n",
    "    df = df_list[i]\n",
    "    df['distance_xy'] = np.sqrt(df['x']**2 + df['y']**2)\n",
    "    df['distance_xz'] = np.sqrt(df['x']**2 + df['z']**2)\n",
    "    df['distance_yz'] = np.sqrt(df['y']**2 + df['z']**2)\n",
    "    df['distance_xyz'] = np.sqrt(df['x']**2 + df['y']**2 + df['z']**2)\n",
    "    joblib.dump(df, os.path.join(output_dir, 'train_0%d.lz4' % (i+1)), compress='lz4')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
